import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import { setStorageToken, getStorageToken } from '@/utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  namespaced: true,
  // 开发模式下启用严格模式
  // strict: process.env.NODE_ENV === 'development',
  state: {
    // 保存登录成功的token信息
    token: getStorageToken()
  },
  mutations: {
    setToken(state, payload) {
      state.token = payload
      // 把token数据给本地存储起来
      setStorageToken(payload)
    }
  },
  actions: {},
  modules: { user }
})
